home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / lightwave / lwmlist / 93.lightwave-00 / 000563_rutgers!well.sf.ca.us!shf_Sun, 1 Aug 93 01:26:23 EDT.msg < prev    next >
Internet Message Format  |  1993-12-31  |  6KB

  1. Received: by bobsbox.rent.com (V1.16/Amiga)
  2.     id AA00000; Sun, 1 Aug 93 01:26:23 EDT
  3. Received: from nkosi.well.sf.ca.us by rutgers.edu (5.59/SMI4.0/RU1.5/3.08) 
  4.     id AA04395; Sun, 1 Aug 93 01:10:33 EDT
  5. Received: from well.sf.ca.us (well.sf.ca.us [192.132.30.2]) by nkosi.well.sf.ca.us (8.5/8.5) with SMTP id WAA16226; Sat, 31 Jul 1993 22:10:30 -0700
  6. Received: by well.sf.ca.us id <13989-1>; Sat, 31 Jul 1993 22:10:09 -0700
  7. Message-Id: <93Jul31.221009pdt.13989-1@well.sf.ca.us>
  8. Date:     Sat, 31 Jul 1993 22:10:05 -0700
  9. From: "Stuart H. Ferguson" <rutgers!well.sf.ca.us!shf>
  10. To: bobsbox.rent.com!lightwave
  11. Subject: Useful ARexx Script for Sequences
  12.  
  13. If you find yourself manipulating image sequences as much as I do, you
  14. may find this little ARexx script useful.  It is used as a shell command
  15. preprocessor and allows any shell command to be invoked iteratively on
  16. a series of images.  This makes it easy to do things like:
  17.  
  18.     Delete images MyFG001 through MyFG030 ...
  19.     cli> seq delete MyFG#30#
  20.  
  21.     Delete every other image from Imgs001 - Imgs020 ...
  22.     cli> seq delete Imgs#2,20,2#
  23.  
  24.     Rename the remaining images as NewSeq001 - NewSeq010 ...
  25.     cli> seq rename Imgs#1,20,2# NewSeq#
  26.  
  27. Have fun ...
  28.  
  29.         Stuart Ferguson        (shf@well.sf.ca.us)
  30.             Prepare to Surge to Sublight Speed!
  31. ----------------
  32.  
  33. /*
  34.  * SEQ -- Command Sequence Processor
  35.  *
  36.  * This takes a shell command with special pattern codes embedded in it
  37.  * and issues a sequence of shell commands generated by filling in the
  38.  * patterns.  This allows for one-line processing of a sequence of files
  39.  * such as LightWave image sequences.
  40.  *
  41.  * Some examples:
  42.  *
  43.  *    CLI> seq copy abc#30# abc#.bku
  44.  *    copy abc001 abc001.bku
  45.  *    copy abc002 abc002.bku
  46.  *     ...
  47.  *    copy abc030 abc030.bku
  48.  *
  49.  *    CLI> seq rename img#1,20,2# ximg#3,10#
  50.  *    rename img001 ximg003
  51.  *    rename img003 ximg004
  52.  *    rename img005 ximg005
  53.  *     ...
  54.  *    rename img017 ximg011
  55.  *    rename img019 ximg012
  56.  *
  57.  * It takes the command line and breaks it up into words.  Each word
  58.  * can contain a sequence pattern which will be expanded into a sequence
  59.  * of words with numbers replacing the pattern code.  The codes can be
  60.  * in the following forms:
  61.  *
  62.  *      pattern form          start    end     step
  63.  *      ------------          -----    ---     ----
  64.  *     #            1    1    1
  65.  *     #N#            1    N    1
  66.  *     #K,N#            K    N    1
  67.  *     #K,N,S#        K    N    S
  68.  *
  69.  * Any word without a pattern is just a constant which gets repeated
  70.  * in each iteration.  The total number of iterations for the combined
  71.  * command is the MAXIMUM number of elements in any sequence.
  72.  *
  73.  * If the command line is preceded by a hyphen (i.e. "seq -copy ..."),
  74.  * the commands will be generated and displayed but not envoked as
  75.  * shell commands.  This allows you to test a complex pattern before
  76.  * letting it work on real files.
  77.  *
  78.  * This should be placed in the "S:" directory and have its script bit
  79.  * set to work as indicated in the above examples.
  80.  *
  81.  * 7/93        Stuart Ferguson
  82.  */
  83.  
  84.  
  85. call addlib("rexxsupport.library",0,-30,0)
  86.  
  87. /* Get command line from shell.
  88.  */
  89. parse arg cmdline
  90.  
  91. /* Look for leading hyphen to see if this is a real command.
  92.  */
  93. forreal = 1
  94. cmdline = strip(cmdline)
  95. if (left(cmdline, 1) = '-') then do
  96.     forreal = 0
  97.     cmdline = strip(substr(cmdline,2))
  98. end
  99.  
  100. /* Get number of words on command line.
  101.  */
  102. narg = words(cmdline)
  103. if (narg < 1) then exit 10
  104.  
  105. /* Convert each word into sequence form and get the max sequence size
  106.  * as the number of iterations.
  107.  */
  108. iter = 1
  109. do i=1 to narg
  110.     templ.i = namebreak(word(cmdline,i))
  111.     iter = max(iter, namecount(templ.i))
  112. end i
  113.  
  114. /* Generate a new command line by expanding each sequence pattern into
  115.  * a specific instance for each iteration.
  116.  */
  117. do k=1 to iter
  118.     cmd = ""
  119.     do i=1 to narg
  120.     cmd = cmd || iname(k,templ.i) || ' '
  121.     end i
  122.  
  123.     say cmd
  124.     if (forreal) then address command cmd
  125. end k
  126.  
  127. exit
  128.  
  129.  
  130.  
  131. /*
  132.  * NameBreak converts a pattern word into a sequence descriptor.  The
  133.  * descriptor consists of five words: name pattern, number of digits,
  134.  * start index, step, end index.  Pattern is a word with a '*' in it
  135.  * where the number will go.
  136.  */
  137. NAMEBREAK: procedure
  138.     parse arg name
  139.  
  140.     /* Find first pattern marker.  If none, this is a constant sequence.
  141.      */
  142.     p1 = pos('#',name)
  143.     if (p1 = 0) then return name || "* 0 1 1 1"
  144.  
  145.     /* Find second pattern marker, if any.
  146.      */
  147.     p2 = pos('#',name,p1+1)
  148.     if (p2 = 0) then p2 = p1
  149.  
  150.     /* Split out head and tail sections.  If no second pattern marker,
  151.      * just set defaults.
  152.      */
  153.     head = substr(name,1,p1-1)
  154.     tail = substr(name,p2+1)
  155.     pat = head || "*" || tail
  156.     if (p1 = p2) then return pat 3 1 1 1
  157.  
  158.     /* Parse sequence numbers.  Step defaults to 1.  Start defaults to 1.
  159.      */
  160.     larg = substr(name,p1+1,p2-p1-1)
  161.     parse var larg n0 ',' n1 ',' step
  162.     if (step = "") then step = 1
  163.     if (n1 = "") then do
  164.     n1 = n0
  165.     n0 = 1
  166.     end
  167.  
  168.     return pat 3 n0 step n1
  169.  
  170.  
  171. /*
  172.  * NameCount takes a sequence descriptor and returns the number of elements
  173.  * defined by the sequence.
  174.  */
  175. NAMECOUNT: procedure
  176.     arg pat ndig n0 step n1 .
  177.     return (n1 - n0 + step) % step
  178.  
  179.  
  180. /*
  181.  * IName takes an index and sequence descriptor and returns the name 
  182.  * generated for the given index.
  183.  */
  184. INAME: procedure
  185.     parse arg i, pat ndig n0 step .
  186.     parse var pat head '*' tail
  187.     num = right(n0 + step * (i - 1), ndig, 0)
  188.     return head || num || tail
  189.  
  190. ----------------- end --------------